<?php declare(strict_types=1);

namespace App\Command;

use Hyperf\Command\Annotation\Command;
use Symfony\Component\Console\Input\InputArgument;

#[Command]
class StatDateUser extends \Hyperf\Command\Command
{

    protected ?string $name = 'stat:date_user';

    public function configure()
    {
        parent::configure();
        $this->setDescription('UserData：用户单日信息统计');
    }

    protected function getArguments()
    {
        return [
            ['date', InputArgument::REQUIRED, '要统计的日期，时间戳（10位）| datetime(Y-m-d)'],
        ];
    }

    public function handle(): void
    {
        $date = $this->input->getArgument('date');
        $this->line('统计日期为' . $date, 'info');
        $todayTime = strtotime(date('Y-m-d 00:00:00'));
        $this->line('当前时间日期为' . date('Y-m-d', $todayTime), 'info');
        if (strtotime(date($date . ' 00:00:00')) >= $todayTime) {
            $this->line('开始时间日期必须在今日之前！', 'warning');
            return;
        }
        $startTime = microtime(true);
        // todo 注入
        $endTime = microtime(true);
        $this->line('用户单日数据统计执行完毕，耗时：' . ($endTime - $startTime) . '秒', 'info');
    }


}